package com.google.code.bankagregator.core.entityServices;

import com.google.code.bankagregator.dao.BankDAO;
import com.google.code.bankagregator.entities.Bank;

import javax.ejb.EJB;
import java.util.List;

/**
 * Bank Service
 */
public class BankService {

    @EJB
    BankDAO bankDAO;

    public void createBank(Bank bank) {
        bankDAO.create(bank);
    }

    public Bank loadBank(int bankId) {
        Bank bank = null;
        bank = bankDAO.getById(bankId);
        return bank;
    }

    public void updateBank(Bank bank) {
        bankDAO.update(bank);
    }

    public void deleteBank(int bankId) {
        bankDAO.delete(bankId);
    }

    public void deleteBank(Bank bank) {
        bankDAO.delete(bank);
    }

    public List<Bank> getAllBanks() {
        List<Bank> banks = null;
        banks = bankDAO.getAll();
        return banks;
    }
}
